package org.kzwl.book.controller.app;

import com.baomidou.mybatisplus.core.metadata.IPage;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.kzwl.comm.pojo.ResponseData;
import org.kzwl.comm.pojo.bo.venues.QueryDetailsBO;
import org.kzwl.comm.pojo.bo.venues.VenueBasicBO;
import org.kzwl.comm.pojo.dto.venues.QueryRecordDTO;
import org.kzwl.comm.pojo.dto.venues.VenuesBasicDTO;
import org.kzwl.comm.pojo.dto.venues.VenuesDetailsDTO;
import org.kzwl.comm.utils.MyUtils;
import org.kzwl.service.web.CuVenuesService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@Api("场馆预约")
@RestController
@RequestMapping("/app-cu-venues")
public class AppCuVenuesController {

    @Autowired
    CuVenuesService cuVenuesService;

    @ApiOperation(value = "场馆预约基础查询")
    @PostMapping("/queryBasic")
    public ResponseData<List<VenuesBasicDTO>> queryBasic(@RequestBody VenueBasicBO bo)
    {
        IPage<VenuesBasicDTO> page = cuVenuesService.queryBasic(bo);
        return new ResponseData<>(page.getRecords());
    }

    @ApiOperation(value = "查询场馆预约详细",notes = "cuUserId(用户编号)-可选，当前用户未登录不填 cuVenuesId(活动id)--必填")
    @PostMapping("/queryDetails")
    public ResponseData<VenuesDetailsDTO> queryDetails(@RequestBody QueryDetailsBO bo)
    {
        VenuesDetailsDTO dto = cuVenuesService.queryDetails(bo);;
        String s = MyUtils.regExHtml(dto.getCuVenuesContent());
        dto.setCuVenuesContent(s);
        return new ResponseData<>(dto);
    }

    @ApiOperation(value = "参与场馆预约")
    @PostMapping("/joinVenues")
    public ResponseData<Void> joinVenues(@RequestBody QueryDetailsBO bo)
    {
        cuVenuesService.joinVenues(bo);;
        return new ResponseData<>();
    }

    @ApiOperation(value = "场馆预约参与记录",notes = "cuUserId(用户编号)-必填")
    @PostMapping("/queryRecord")
    public ResponseData<QueryRecordDTO> queryRecord(@RequestBody QueryDetailsBO bo)
    {
        QueryRecordDTO dto = cuVenuesService.queryRecord(bo);;
        return new ResponseData<>(dto);
    }
}
